home *** CD-ROM | disk | FTP | other *** search
- /*
- cvclass.cpp
-
- Class hierarchy window (main window)
-
- C++/Views 2.0 Demo
- Copyright (c) 1992, by Liant Software Corp.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- */
-
- #include "cvclass.h"
- #include "cvdemovw.h"
- #include "listbox.h"
- #include "port.h"
- #include "font.h"
- #include "brush.h"
- #include "shade.h"
- #include "messengr.h"
- #include "tagstrm.h"
- #include "editbox.h"
-
- #include "cvclinfo.h"
- #include "cvcltree.h"
-
- defineClass(ClassView, VMdiView)
-
- ClassView::ClassView()
- {
- ;
- }
-
- ClassView::ClassView(VFrame &f, DemoAppView *parent)
- : VMdiView("ClassIcon", f, (VWindow *) parent, StyleBorder | StyleTitle | StyleCloseBox | StyleSizable)
- {
- mainWin = parent;
-
- setTitle("C++/Views Classes");
-
- setBackground(new VBrush(LightGray));
-
- /* create an edit box */
- msgBox = new VEditBox(VFrame(0.4F, 0.0F, 0.6F, 0.3F), this,
- StyleBorder | StyleVertical | StyleWordWrap | StyleReadOnly);
-
-
- textFont = new VFont("New Times Roman", 11, TRUE);
- msgBox->setFont(textFont);
-
- /* create a list box */
- listBox = new VListBox(VFrame(0.0F, 0.0F, 0.4F, 0.3F), this, StyleBorder);
- listBox->uponClick(this, methodOf(ClassView, listClick),
- methodOf(ClassView, listDblClick));
-
- listBox->setFont(textFont);
-
- /* create the class tree view */
- treeView = new ClassTreeView(VFrame(0.0F, 0.3F, 1.0F, 0.7F), this);
- treeView->uponClick(this, methodOf(ClassView, classSelected));
-
- /* load the starting messages */
- // treeView->loadFromStream(cvTextFile->getMessage("ClassList:Data Classes"));
- treeView->update();
- msgBox->putText(cvTextFile->getMessage("ClassIntro:General").gets());
-
- /* read in list of class lists from the message file */
- VTagStream tagStrm;
- VString cmd;
- VStream clist(cvTextFile->getMessage("ClassList:List"));
-
- tagStrm.beginScan(&clist, NIL);
- tagStrm.tags('(', ')');
-
- while(tagStrm.getTag(cmd)) {
- listBox->appendString(cmd.gets());
- }
-
- /* make sure the "About this Window" data is set up */
- mainWin->setAboutNames("Class:About", "cvclass.cpp");
- }
-
- ClassView::~ClassView()
- {
- /* destroy background brush (if present) */
- delete getBackground();
-
- delete textFont;
- }
-
- boolean ClassView::free()
- {
- delete this;
- return(TRUE);
- }
-
- boolean ClassView::close()
- /*
- The user has closed the window.
- Notify the main window so that it can update the main menu bar
- */
- {
- mainWin->classView = 0;
- mainWin->updateMenu();
- return(FALSE);
- }
-
- boolean ClassView::listClick(int index)
- /*
- Mouse clicked on the list box
- */
- {
- VString idx("ClassList:");
- VString *temp;
-
- temp = listBox->selectedString();
- idx.concat(temp);
-
- /* load a new class tree */
- treeView->loadFromStream(cvTextFile->getMessage(idx.gets()));
- treeView->update();
-
- /* update the message */
- idx.puts("ClassIntro:");
- idx.concat(temp);
- msgBox->putText(cvTextFile->getMessage(idx.gets()).gets());
-
- delete temp;
-
- return(TRUE);
- }
-
- boolean ClassView::listDblClick(int index)
- /*
- Mouse double-clicked on the list box
- */
- {
- return(TRUE);
- }
-
- boolean ClassView::classSelected()
- {
- ClassInfo *cinfo = treeView->getCurrClass();
-
- if (cinfo) {
- /* update message text */
- VString idx("Class:");
- idx.concat(cinfo->getName());
- msgBox->putText(cvTextFile->getMessage(idx.gets()).gets());
- }
-
- return(TRUE);
- }
-
- boolean ClassView::givenFocus()
- /*
- Our window has just been given input focus
- */
- {
- /* set the data for the About this Window dialog */
- mainWin->setAboutNames("Class:About", "cvclass.cpp");
-
- /* carry on with default window behavior, return FALSE */
- return(FALSE);
- }
-
-